<?php
/*
 * Function:地区相关的代码
 * Project :SuperEMall
 *
 * Dreamxyp(QQ:31996798) - GZ - PHP - area.class.php
 * Coding  :xiayiping[xiayiping_xyp@163.com]
 * Created on 2007-12-24
 */
 class area 
 {
     /**
      * 功能:从ID到name
      */
     public static function id2name($db,$arr)
     {
		 $ca = new ca("area","area",3600);
		 if(!$area = $ca->get())
		 {
		    for($i=1;$i<=3;$i++)
			{
			    $rss= array();
			    $rs = $db->dataArray("select * from area_c{$i}");
				foreach($rs as $v) $rss[$v["a{$i}id"]] = $v["name"];
				$area["a{$i}id"] = $rss;
			}
			$ca->put($area);
		}
		$rs = array();
		if(!is_array($arr)) $arr = array("a1id"=>$arr);
		for($i=1;$i<=3;$i++)
		{
			$key = "a{$i}id";
			if($arr[$key]) $rs["a{$i}id"] = $area["a{$i}id"][$arr[$key]];
		}
		return $rs;
     }
 }
?>
